<?php

class LoginView{
	
	private $user = "user";
	private $password = "pass";
	private $login = "login";
	private $logout = "logout";
			
	//Skapa inlogginsrutan
	public function CreateLoginBox(){				
		$loginForm = "<div id='login'>
						<form action='index.php' method='get'>
							<fieldset>
								<legend>Login</legend>
									<label for='user'>User:</label>
									<input type='text' id='user' name='$this->user' />
									<br />
									<label for='pass'>Password:</label>
									<input type='password' id='pass' name='$this->password' />
									<br />
									<input type='checkbox' value='remember' id='remember' />
									<label for='remember'>Kom ihåg mig</label>
									<br />
									<input type='submit' name='$this->login' value='Login' />
							</fieldset>
						</form>
					</div>\n";
		
		return $loginForm;
	}
	
	//Utloggningsknapp
	public function CreateLogoutBox(){
		return "<form action='index.php' method='get' >
					<input type='submit' name='$this->logout' value='Logga ut' />
				</form>";
	}
	
	public function GetUserName(){
			
		if (isset($_GET[$this->user]) == true) {
      		return $_GET[$this->user];
    	}
    	return NULL;
	}
	
	public function GetPassword(){
		if (isset($_GET[$this->password]) == true) {
      		return $_GET[$this->password];
		}
		return NULL;
	}
	
	public function TriedToLogin(){
		if(isset($_GET[$this->login])){
			return true;
		}
		return false;
	}
	
	public function TriedToLogOut(){
		if(isset($_GET[$this->logout])){
			return true;
		}
		return false;
	}
}
?>

